﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.JiesuanguanliDemo.JinxiangDataManager.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.JiesuanguanliDemo.JinxiangDataManager
{
    public class JinxiangDataService : AsyncCrudAppService<JinxiangData, JinxiangDataInputDto, int, PageJinxiangDataRequestDto, JinxiangDataCreateDto, JinxiangDataUpdateDto>, IJinxiangDataService
    {
        public JinxiangDataService(
       IRepository<JinxiangData, int> repository) : base(repository)
        {

        }
        /// <summary>
        /// 自定义分页条件查询, 需要重写父类的CreateFilteredQuery方法,让其进行自定义条件筛选
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        protected override IQueryable<JinxiangData> CreateFilteredQuery(PageJinxiangDataRequestDto input)
        {
            return base.CreateFilteredQuery(input)

                 .WhereIf(!string.IsNullOrEmpty(input.danwei), c => c.danwei.Contains(input.danwei))
                  .WhereIf(!string.IsNullOrEmpty(input.leixing), c => c.leixing.Contains(input.leixing))
                 
                    .WhereIf(input.riqi.HasValue, c => c.riqi == input.riqi);
        }
    }
}
